/*
 *  Copyright 2002 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
/*
 *  ======== diff_ti_ialg.c ========
 *  Implementation of the DIFF_TI.h interface; TI's implementation 
 *  of the IDIFF interface. 
 */
#pragma CODE_SECTION(DIFF_TI_alloc, ".text:algAlloc")
#pragma CODE_SECTION(DIFF_TI_free, ".text:algFree")
#pragma CODE_SECTION(DIFF_TI_initObj, ".text:algInit")
#pragma CODE_SECTION(DIFF_TI_numAlloc, ".text:algNumAlloc")
 
#include <std.h>

#include "idiff.h"
#include "diff_ti.h"
#include "diff_ti_priv.h"

#define OBJECT  0
#define NUMBUFS 1


/*
 *  ======== DIFF_TI_alloc ========
 *  Return a table of memory descriptors that describe the memory needed 
 *  to construct a DIFF_TI_Obj structure.
 */
Int DIFF_TI_alloc(const IALG_Params *diffParams, IALG_Fxns **fxns, 
                    IALG_MemRec memTab[])
{
    const IDIFF_Params *params = (Void *)diffParams;
    
    if (params == NULL) 
    {
        params = &IDIFF_PARAMS;       /* set default parameters */
    }

    /* Request memory for DIFF object */
    memTab[OBJECT].size       = sizeof(DIFF_TI_Obj);
    memTab[OBJECT].alignment  = 4;
    memTab[OBJECT].space      = IALG_EXTERNAL;
    memTab[OBJECT].attrs      = IALG_PERSIST;
           
    return (NUMBUFS);
}

/*
 *  ======== DIFF_TI_free ========
 *  Return a table of memory pointers that should be freed.  Note
 *  that this should include *all* memory requested in the 
 *  DIFF_TI_alloc operation above.
 */
Int DIFF_TI_free(IALG_Handle handle, IALG_MemRec memTab[])
{
    DIFF_TI_Obj *diff = (Void *)handle;
    
    DIFF_TI_alloc(NULL, NULL, memTab);
      
    memTab[OBJECT].base = diff;
     
    return (NUMBUFS);
}

/*  ======== DIFF_TI_initObj ========
 *  Initialize the memory allocated for our instance.
 */
Int DIFF_TI_initObj(IALG_Handle handle, const IALG_MemRec memTab[], 
                      IALG_Handle p, const IALG_Params *diffParams)
{
//    DIFF_TI_Obj *diff = (Void *)handle;
    const IDIFF_Params *params = (Void *)diffParams;

    if (params == NULL) 
    {
        params = &IDIFF_PARAMS;  /* set default parameters */
    }
	
    return (IALG_EOK);
}

/*  ======== DIFF_TI_numAlloc ========
 *  Returns the number of records needed for the MEM tab by the client.
 */
Int DIFF_TI_numAlloc()
{
    return(NUMBUFS);
}


